package com.example.app5.bitmap;

import android.graphics.Bitmap;
import android.widget.ImageView;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class LoadImageTask {
    private static final int THREAD_POOL_SIZE = 5; // 线程池大小
    private static final ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);

    public static void loadImage(final Bitmap bitmap, final ImageView imageView) {
        Runnable task = new Runnable() {
            @Override
            public void run() {
                imageView.post(new Runnable() {
                    @Override
                    public void run() {
                        imageView.setImageBitmap(bitmap);
                    }
                });
            }
        };

        // 将任务提交到线程池中
        executorService.execute(task);
    }
}
